package com.codefish.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.codefish.entity.SysRoleEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Classname SysRoleDao
 * @Description 角色表
 * @Date 2021/5/3 11:59
 * @Created 学兔斯基眯眼看世界
 */
@Repository
@Mapper
public interface SysRoleDao extends BaseMapper<SysRoleEntity> {

    /**
     * 根据名称查询角色数据
     * @param name
     * @return
     */
    SysRoleEntity getRole(String name);

    void saveRolePermission(@Param("roleId") Long roleId, List<Long> permissionIds);

    int deleteRolePermission(Long roleId);

    @Select("SELECT permission_id FROM `sys_role_permission` WHERE role_id = #{id}")
    List<Long> queryPermissionIdsByRoleId(Long id);
}
